package com.scau.classOnline.common;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter implements Converter<String,Date> {
    private SimpleDateFormat simpleDateFormat =  new SimpleDateFormat("yyyy-MM-dd");

    @Override
    public Date convert(String source) {
        if ("".equals(source) || source == null){
            return null;
        }
        try {
            return simpleDateFormat.parse(source);
        }catch (ParseException e){
            e.printStackTrace();
        }
        return null;
    }
}
